/**
 * Created by ruiyuan on 15-9-21.
 */
module.exports = function (app) {
    var market = require('../controllers/market-controller');
    var tokenFilter = require('../filters/token-filter');

    app.all('/rest/' + RESTFullServiceVersion + '/market/*', tokenFilter.doCheckToken);

    app.get('/rest/' + RESTFullServiceVersion + '/market/banners/:token/:deviceId', market.getMarketBanners);
    app.get('/rest/' + RESTFullServiceVersion + '/market/goods/hotQueryTerms/:token/:deviceId', market.getGoodsHotQueryTerms);
    app.get('/rest/' + RESTFullServiceVersion + '/market/goods/categoryList/:token/:deviceId', market.getGoodsCategoryList);
    app.post('/rest/' + RESTFullServiceVersion + '/market/newGoods/:token/:deviceId', market.addNewGoods);
    app.post('/rest/' + RESTFullServiceVersion + '/market/updateGoods/:goodsId/:token/:deviceId', market.updateGoods);
    app.get('/rest/' + RESTFullServiceVersion + '/market/goods/list/:ts/:token/:deviceId', market.getGoodsList);
    app.get('/rest/' + RESTFullServiceVersion + '/market/goods/recList/:ts/:token/:deviceId', market.getRecGoodsList);
    app.get('/rest/' + RESTFullServiceVersion + '/market/goods/saleList/:ts/:token/:deviceId', market.getSaleGoodsList);

    app.get('/rest/' + RESTFullServiceVersion + '/market/followGoods/list/:ts/:token/:deviceId', market.getFollowGoodsList);


    app.get('/rest/' + RESTFullServiceVersion + '/market/getGoodsDetail/:goodsId/:width/:token/:deviceId', market.getGoodsDetail);
    app.get('/rest/' + RESTFullServiceVersion + '/market/getGoodsDetailForApp/:goodsId/:token/:deviceId', market.getGoodsDetailForApp);
    app.get('/rest/' + RESTFullServiceVersion + '/market/myGoods/:ts/:token/:deviceId', market.getMyGoods);
    app.get('/rest/' + RESTFullServiceVersion + '/market/getOtherGoods/:user/:ts/:token/:deviceId', market.getOtherGoods);
    app.get('/rest/' + RESTFullServiceVersion + '/market/getRepliesByGoodsId/:goodsId/:token/:deviceId', market.getRepliesByGoodsId);
    app.post('/rest/' + RESTFullServiceVersion + '/market/updateReleaseDate/:goodsId/:token/:deviceId', market.updateReleaseDate);
    app.post('/rest/' + RESTFullServiceVersion + '/market/queryDeal/:goodsId/:token/:deviceId', market.queryDeal);
    app.post('/rest/' + RESTFullServiceVersion + '/market/delGoods/:goodsId/:token/:deviceId', market.delGoods);

    //opm-v2调用
    app.delete('/rest/' + RESTFullServiceVersion + '/backoffice/delGoods/:goodsId', market.backdelGoods);

    app.post('/rest/' + RESTFullServiceVersion + '/market/delGoodsReply/:goodsId/:replyId/:token/:deviceId', market.delGoodsReply);
    app.get('/rest/' + RESTFullServiceVersion + '/market/addReply/:token/:deviceId', market.addReply);

    app.get('/rest/' + RESTFullServiceVersion + '/market/saleNotify/:token/:deviceId', market.getSaleNotifyMessage);
    app.post('/rest/' + RESTFullServiceVersion + '/market/saleRecord/:token/:deviceId', market.addSaleRecord);

    app.post('/rest/' + RESTFullServiceVersion + '/market/goodsDetail/sendMessage/:token/:deviceId', market.sendMessage);

    /* 宝宝树66小区 sprint5 闲置搜索页 增加闲置分类搜索 add wangcan 20171115 start */
    // 1120-commit-master
    app.post('/rest/' + RESTFullServiceVersion + '/market/goods/search/:token/:deviceId', market.searchGoods);
    // app.get('/rest/' + RESTFullServiceVersion + '/market/goods/search/:keyword/:goodsClaId/:ts/:token/:deviceId', market.searchGoods);

    // app.post('/rest/' + RESTFullServiceVersion + '/market/goods/searchGoodsCategory/:token/:deviceId', market.searchGoodsCategoryList);
    app.get('/rest/' + RESTFullServiceVersion + '/market/goods/searchGoodsCategory/:token/:deviceId', market.searchGoodsCategoryList);
    /* 宝宝树66小区 sprint5 闲置搜索页 增加闲置分类搜索 add wangcan 20171115 end */


    // non-app用户集市调用
    app.get('/rest/' + RESTFullServiceVersion + '/public/market/banners', market.publicGetMarketBanners);
    app.get('/rest/' + RESTFullServiceVersion + '/public/market/goods/list/:ts', market.publicGetGoodsList);
    app.get('/rest/' + RESTFullServiceVersion + '/public/market/getGoodsDetail/:goodsId/:width', market.publicGetGoodsDetail);
    app.get('/rest/' + RESTFullServiceVersion + '/public/market/getRepliesByGoodsId/:goodsId', market.getRepliesByGoodsId);

    /* 宝宝树66小区 sprint5 66小区APP"我的"页面 新增我的拼团收藏功能 add wangcan 20171117 start */
    // APP调用-我的拼团收藏 /:token/:deviceId
    app.post('/rest/' + RESTFullServiceVersion + '/public/market/goods/getFightGroupsCollectList/:ts/:deviceId', market.getFightGroupsCollectList);
    // app.get('/rest/' + RESTFullServiceVersion + '/public/market/goods/getFightGroupsCollectList/:ts/:token/:deviceId', market.getFightGroupsCollectList);
    /* 宝宝树66小区 sprint5 66小区APP"我的"页面 新增我的拼团收藏功能 add wangcan 20171117 end */


};
